Skip to content

feat: bypass the proxy for the hosts listed in nonProxyHosts - #1577

Merged
jlouvel merged 4 commits into
3.0from
fix/netty-non-proxy-hosts
Nov 1, 2026
Merged

jlouvel merged 4 commits into
3.0from
fix/netty-non-proxy-hosts

Conversation

@jlouvel

@jlouvel jlouvel commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #401. Based on #1575.

When a proxy was configured, the Netty client sent every request through it, including requests to localhost and internal hosts.

Changes

  • NettyClientHelper:
    • New nonProxyHosts connector parameter, falling back to the http.nonProxyHosts system property. It uses the JDK syntax: host names separated by |, each with an optional leading or trailing * wildcard, matched ignoring case. As in the JDK, the list applies to both HTTP and HTTPS requests.
    • New public getNonProxyHosts(). getProxy(secure, targetHost) now returns null for matching hosts, so these requests use origin-form request lines, connect directly, and are not tunneled.
    • The parameter table Javadoc is updated.
  • NettyClientCall: the tunnel check passes the target host.
  • ProxyTestCase: loopback hosts bypassed by default, bypass with the parameter (with spaces and mixed case) and with the system property over HTTPS, and other hosts still proxied, including a check that local doesn't match localhost.
  • changes.md: entry under Enhancements.

Loopback default

As with the JDK, when neither the parameter nor http.nonProxyHosts is set, the loopback addresses are excluded by default: localhost|127.*|[::1]|0.0.0.0|[::0]. An empty value excludes no host, as in the JDK. This is a small behavior change: a client with a proxy configured now connects directly to localhost. The proxy tests set nonProxyHosts to an empty string so they can still use a test proxy on localhost.

Validation

ProxyTestCase: 11 tests pass.

🤖 Generated with Claude Code

@jlouvel

jlouvel commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Full module verify passed at the top of the stack (#1580 branch, which includes this PR): 2,228 tests, 0 failures; JaCoCo checks met; SpotBugs 8 findings (threshold 9).

@jlouvel
jlouvel force-pushed the fix/netty-non-proxy-hosts branch from a3b9e8d to 599b447 Compare October 31, 2026 07:44
@jlouvel
jlouvel force-pushed the fix/netty-non-proxy-hosts branch from 599b447 to fac8722 Compare November 1, 2026 14:56
@jlouvel
jlouvel force-pushed the fix/netty-non-proxy-hosts branch from fac8722 to 2bd2e6f Compare November 1, 2026 16:18
Base automatically changed from fix/netty-https-proxy-properties to 3.0 November 1, 2026 17:57
@jlouvel jlouvel self-assigned this Nov 1, 2026
@jlouvel
jlouvel added this pull request to stack #1626 November 1, 2026 20:12
@jlouvel
jlouvel force-pushed the fix/netty-non-proxy-hosts branch from 0cfaa9b to d625c38 Compare November 1, 2026 20:16
jlouvel and others added 4 commits November 1, 2026 16:24
When a proxy was configured, the Netty client sent every request through
it, including requests to localhost and internal hosts.

- NettyClientHelper: new "nonProxyHosts" parameter, defaulting to the
  "http.nonProxyHosts" system property, with the JDK syntax: host names
  separated by "|", with an optional leading or trailing "*" wildcard,
  matched ignoring case. It applies to HTTP and HTTPS requests. Unlike
  the JDK, no host is excluded by default.
- ProxyTestCase: parameter and system property bypass, other hosts still
  proxied.

Closes #401.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com>
As with the JDK, nonProxyHosts defaults to localhost|127.*|[::1]|0.0.0.0|[::0]
when neither the parameter nor the http.nonProxyHosts system property is set.
An empty value excludes no host.

Refs #401

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the HTTP2 transport mode, the Netty client sent the HTTP/2 connection
preface (prior knowledge) to the forward proxy for http:// requests. HTTP
proxies generally only speak HTTP/1.1 to clients, so these requests
failed.

- NettyClientHelper: cleartext connections to a forward proxy use
  HTTP/1.1 with absolute-form request targets, logged at FINE level.
  HTTPS requests through CONNECT tunnels still negotiate HTTP/2 with ALPN.
- ProxyTestCase: HTTP2 mode request through the forward proxy.

Closes #1571.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jlouvel
jlouvel force-pushed the fix/netty-non-proxy-hosts branch from d625c38 to 8baeea1 Compare November 1, 2026 21:24
@jlouvel
jlouvel merged commit f1b5028 into 3.0 Nov 1, 2026
1 check failed
@jlouvel
jlouvel deleted the fix/netty-non-proxy-hosts branch November 1, 2026 21:24
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant